/**   
 * @Title: LotteryRecordDetailAct.java 
 * @Package: com.esun.rabbit2.viewer.mainact.mylotteryact 
 * @Description: (购彩记录详情) 
 * @Author: Billy qigs@500wan.com   
 * @Date: 2011-6-28 下午03:52:58  
 * Copyright (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.viewer.mainact.mylotteryact.lotteryrecord;

import java.util.List;

import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.esun.config.Config;
import com.esun.config.ImageZhanJi;
import com.esun.config.Key;
import com.esun.config.Language;
import com.esun.model.HemaiDetailInfo;
import com.esun.model.LotteryRecordDetailFootballInfo;
import com.esun.model.UserInfo;
import com.esun.network.ConnectionChangeReceiver;
import com.esun.rabbit2.communicaters.CheDanCommunicater;
import com.esun.rabbit2.communicaters.GetUserIconCommunicater;
import com.esun.rabbit2.communicaters.lotteryrecord.LotteryRecordDetailFootballCommunicater;
import com.esun.ui.R;
import com.esun.util.ShowZhanji;
import com.esun.util.ViewerUtil;
import com.esun.util.img.ImageUtils;
import com.esun.util.img.db.ImageDB;
import com.esun.util.log.EDebug;

/**
 * @ClassName: LotteryRecordDetailAct
 * @Description: (购彩记录详情)
 * @Author: Billy qigs@500wan.com
 * @Date: 2011-6-28 下午03:52:58
 */
public class LotteryRecordDetailFootballAct extends Activity implements OnClickListener {

	private ImageButton btnBack;
	private Button btnCheDan;
	private Button btnMore;
	private ImageView imageFaQiRen;
	private TextView tvPlayName;
	private TextView tvAddTime;
	private TextView tvProID;

	private TextView tvFaQiRen;
	private TextView tvLotteryMoney;
	private TextView tvLotteryCount;

	private TextView tvAllMoney;
	private TextView tvBeiShu;
	private TextView tvEachMoney;
	private TextView tvFenSHu;
	private TextView tvGGType;
	private TextView tvIssuc;
	private TextView tvState;
	private TextView tvGetMoney;
	private TextView tvJinDu;
	private TextView tvBaoDiMoney;
	private TextView tvTiCheng;

	private LinearLayout linearZhanJi;
	private LinearLayout linearProgramContent;
	private LinearLayout linearCheDan;
	private LinearLayout linearZhanJiWai;
	private LinearLayout linearHeMai;

	private LotteryRecordDetailFootballCommunicater footballDetailCommunicater;
	private LotteryRecordDetailFootballInfo listInfo;
	private GetUserIconCommunicater getUserIconCommunicater;
	private Handler handlerGetLotteryRecordDetail;
	private ProgressDialog progressDialog;
	private CheDanCommunicater cheDanCommunicater;
	private String serverMessage;
	private String playID;
	private String lotid;
	private String id;
	private String uid;
	private String fauserName;
	private String urlTxt = Config.TXTURLFOOTBALL;;
	private final int GET_LOTTERYRECORDDETAIL_SUCCEED = 1001; // 获取详情通信成功、失败
	private final int GET_LOTTERYRECORDDETAIL_FAIL = 1002;
	private final int CHEDAN_SUCCEED = 1003; // 撤单通信成功、失败
	private final int CHEDAN_FAIL = 1004;
	private static final int REPLACE_IMAGE = 1006;
	private static final int GET_ICONNAME_SUCCEED = 1007;
	private static final int GET_ICONNAME_FAIL = 1008;
	private static final int BUTTON_CHECK_MORE = 5689;
	private boolean isShow = true;
	private boolean isShowTXT = false;
	private Bundle bundle;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.lotteryrecord_detailfootball_act);

		initUI();
		initHandler();
	}

	// 初始化
	public void initUI() {

		progressDialog = ViewerUtil.showProgressDialog(LotteryRecordDetailFootballAct.this, getResources().getString(R.string.loading_text));
		progressDialog.show();

		bundle = this.getIntent().getExtras();
		lotid = bundle.getString("lotid");
		id = bundle.getString("id");
		uid = bundle.getString("uid");

		listInfo = new LotteryRecordDetailFootballInfo();

		new ImageZhanJi();
		imageFaQiRen = (ImageView) findViewById(R.id.lotteryrecord_detailfootball_act_image_faQiRen);

		btnBack = (ImageButton) findViewById(R.id.lotteryrecord_detailfootball_act_btn_back);
		btnBack.setOnClickListener(this);
		btnCheDan = (Button) findViewById(R.id.lotteryrecord_detailfootball_act_btn_cheDan);
		btnCheDan.setOnClickListener(this);

		tvPlayName = (TextView) findViewById(R.id.lotteryrecord_detailfootball_act_tv_playType);
		tvProID = (TextView) findViewById(R.id.lotteryrecord_detailfootball_act_tv_proid);
		tvAddTime = (TextView) findViewById(R.id.lotteryrecord_detailfootball_act_tv_lotteryTime);
		tvFaQiRen = (TextView) findViewById(R.id.lotteryrecord_detailfootball_act_tv_faQIRen);
		tvLotteryMoney = (TextView) findViewById(R.id.lotteryrecord_detailfootball_act_tv_winMoney);
		tvLotteryCount = (TextView) findViewById(R.id.lotteryrecord_detailfootball_act_tv_winCount);
		tvAllMoney = (TextView) findViewById(R.id.lotteryrecord_detailfootball_act_tv_proMoney);
		tvBeiShu = (TextView) findViewById(R.id.lotteryrecord_detailfootball_act_tv_beiShu);
		tvEachMoney = (TextView) findViewById(R.id.lotteryrecord_detailfootball_act_tv_eachMoney);
		tvFenSHu = (TextView) findViewById(R.id.lotteryrecord_detailfootball_act_tv_fenShu);
		tvGGType = (TextView) findViewById(R.id.lotteryrecord_detailfootball_act_tv_ggType);
		tvIssuc = (TextView) findViewById(R.id.lotteryrecord_detailfootball_act_tv_Issuc);
		tvState = (TextView) findViewById(R.id.lotteryrecord_detailfootball_act_tv_lotteryState);
		tvGetMoney = (TextView) findViewById(R.id.lotteryrecord_detailfootball_act_tv_getMoney);
		tvBaoDiMoney = (TextView) findViewById(R.id.lotteryrecord_detailfootball_act_tv_baoDiMoney);
		tvTiCheng = (TextView) findViewById(R.id.lotteryrecord_detailfootball_act_tv_tiCheng);
		tvJinDu = (TextView) findViewById(R.id.lotteryrecord_detailfootball_act_tv_jinDu);

		linearZhanJi = (LinearLayout) findViewById(R.id.lotteryrecord_detailfootball_act_linear_zhanJi);
		linearProgramContent = (LinearLayout) findViewById(R.id.lotteryrecord_detailfootball_act_linear_proContent);
		linearCheDan = (LinearLayout) findViewById(R.id.lotteryrecord_detailfootball_act_linear_bottom);
		linearZhanJiWai = (LinearLayout) findViewById(R.id.lotteryrecord_detailfootball_act_linear_zhanJiWai);
		linearHeMai = (LinearLayout) findViewById(R.id.lotteryrecord_detailfootball_act_linear_heMai);

		getLotteryRecordDetailThread();
	}

	// 获取详细信息线程
	public void getLotteryRecordDetailThread() {
		new Thread() {

			@Override
			public void run() {
				// TODO Auto-generated method stub
				footballDetailCommunicater = new LotteryRecordDetailFootballCommunicater();
				Message msg = new Message();
				try {
					boolean isSucceed = footballDetailCommunicater.isGetLotteryRecordDetail(lotid, id);
					serverMessage = footballDetailCommunicater.getServerMsg();
					EDebug.o(this, serverMessage + "       " + footballDetailCommunicater.getErrorMSG());
					if (isSucceed) {
						msg.what = GET_LOTTERYRECORDDETAIL_SUCCEED;
					} else {
						msg.what = GET_LOTTERYRECORDDETAIL_FAIL;
					}
					handlerGetLotteryRecordDetail.sendMessage(msg);
				} catch (Exception e) {
					msg.what = Config.CONNECTION_FAIL;
					handlerGetLotteryRecordDetail.sendMessage(msg);
				}
			}
		}.start();
	}

	// 通讯结果处理
	public void initHandler() {
		handlerGetLotteryRecordDetail = new Handler() {

			@Override
			public void handleMessage(Message msg) {
				// TODO Auto-generated method stub
				super.handleMessage(msg);
				switch (msg.what) {
				case GET_LOTTERYRECORDDETAIL_SUCCEED:
					listInfo = footballDetailCommunicater.updateFootballDetailInfo();
					communicaterSucceed(listInfo);
					break;

				case GET_LOTTERYRECORDDETAIL_FAIL:
					if (isShow) {
						ViewerUtil.showTipDialog(LotteryRecordDetailFootballAct.this, serverMessage, false);
					}
					break;

				case CHEDAN_SUCCEED:
					EDebug.o(this, "撤单成功");
					UserInfo.getUserInfo().setUserBalance(cheDanCommunicater.getMoney());
					if (isShow) {
						ViewerUtil.showTipDialog(LotteryRecordDetailFootballAct.this, "撤单成功", false);
					}
					break;

				case CHEDAN_FAIL:
					EDebug.o(this, "撤单失败");
					if (isShow) {
						ViewerUtil.showTipDialog(LotteryRecordDetailFootballAct.this, serverMessage, false);
					}
					break;

				case Config.CONNECTION_FAIL:
					if (isShow) {
					  
						//ViewerUtil.showTipDialog(LotteryRecordDetailFootballAct.this, Language.STR_CONNECTIONFAIL, false);
						Toast.makeText(LotteryRecordDetailFootballAct.this, Language.STR_CONNECTIONFAIL, 0).show();
					}
					break;

				case REPLACE_IMAGE:
					Bitmap bm = (Bitmap) msg.obj;
					imageFaQiRen.setImageBitmap(bm);

					break;

				case GET_ICONNAME_SUCCEED:
					getAvatar();
					break;

				case GET_ICONNAME_FAIL:
					EDebug.o(LotteryRecordDetailFootballAct.this, "get icon name fail");
					break;

				default:
					break;
				}
				progressDialog.dismiss();
			}
		};
	}

	// 详情显示
	public void communicaterSucceed(LotteryRecordDetailFootballInfo list) {
		// 是否合买
		if (list.getIsHm().equals("0")) {
			linearHeMai.setVisibility(View.GONE);
		} else {
			tvBaoDiMoney.setText("￥" + list.getBaoDiMoney());
			tvTiCheng.setText(list.getTiCheng() + "%");
			tvJinDu.setText(list.getJinDu() + "%");
			if (Integer.valueOf(list.getJinDu()) + Integer.valueOf(list.getBaoDi()) < 50) {
				linearCheDan.setVisibility(View.VISIBLE);
			}
		}
		tvFenSHu.setText(list.getFenShu() + "份");
		fauserName = list.getFaQiRen();
		// 获取用户头像
		threadGetUserIcon();
		playID = list.getPlayID();

		tvPlayName.setText(list.getPlayName());
		tvAddTime.setText(list.getAddTime());
		tvProID.setText(list.getProID());
		tvFaQiRen.setText(list.getFaQiRen());
		tvLotteryMoney.setText("￥" + list.getLotteryMoney());
		tvLotteryCount.setText(list.getLotteryCount() + "次");
		tvAllMoney.setText("￥" + list.getAllMoney());
		tvBeiShu.setText(list.getBeiShu() + "倍");
		tvEachMoney.setText("￥" + list.getOneMoney());
		if (list.getIssuc().equals("0")) {
			tvIssuc.setText("未出票");
		} else if (list.getIssuc().equals("1")) {
			tvIssuc.setText("已出票");
		}
		tvGGType.setText(list.getGGTypeName());
		if (list.getState().equals("0")) {// 未开奖
			tvState.setText("等待开奖");
		} else if (list.getState().equals("1")) {// 未算奖
			tvState.setText("未算奖");
		} else if (list.getState().equals("2")) {// 未中奖
			tvState.setText("未中奖");
		} else if (list.getState().equals("3")) {// 未派奖
			tvState.setText("未派奖");
		} else if (list.getState().equals("4")) {// 已派奖
			tvState.setText("已派奖");
			tvGetMoney.setText("￥" + list.getWinMoney().substring(0, list.getWinMoney().indexOf(".") + 3));
		}

		zhanJiShow(list);
		programContentDeal(list);
	}

	/**
	 * 2012-3-15 kael修改 战绩计算和显示
	 * 
	 * @param list
	 */
	public void zhanJiShow(LotteryRecordDetailFootballInfo list) {
		// 金钻
		String golddiamond = list.getGoldDiamond();
		// 银钻
		String silverdiamond = list.getSilverDiamond();
		// 金星
		String goldstar = list.getGoldStar();
		// 银星
		String silverstar = list.getSilverStar();
		// 金杯
		String goldcup = list.getGoldCup();
		ShowZhanji zhanji = new ShowZhanji(LotteryRecordDetailFootballAct.this);
		// 获取显示战绩星级图片的list
		List<ImageView> zhanjilist = zhanji.showzhanji(golddiamond, silverdiamond, goldstar, silverstar, goldcup);
		// 判断是否有战绩
		int size = zhanjilist.size();
		if (size == 0) {// 没有战绩就不显示战绩的linear
			linearZhanJiWai.setVisibility(View.GONE);
		} else {// 有战绩就将list中的ImageView添加到显示战绩的linear
			for (int i = 0; i < zhanjilist.size(); i++) {
				linearZhanJi.addView(zhanjilist.get(i));
			}
		}
	}

	// 方案内容显示处理
	private void programContentDeal(LotteryRecordDetailFootballInfo list) {

		if (list.getFileCode().contains("txt")) {

			if (list.getIsUpload().equals(Config.NUM1)) {

				if (list.getFaQiRen().equals(UserInfo.getUserInfo().getUserName())) {
					// 显示更多按钮
					isShowTXT = true;
					btnMore = new Button(LotteryRecordDetailFootballAct.this);
					btnMore.setText("查看上传方案");
					btnMore.setTextColor(getResources().getColor(R.color.solid_black));
					btnMore.setWidth(LayoutParams.FILL_PARENT);
					btnMore.setId(BUTTON_CHECK_MORE);
					btnMore.setOnClickListener(this);
					linearProgramContent.addView(btnMore);
				} else {
					if (list.getIsShow().equals("1")) {
						EDebug.o(this, "截止后公开");
						TextView tvNoContent = new TextView(LotteryRecordDetailFootballAct.this);
						tvNoContent.setText("截止后公开");
						tvNoContent.setTextColor(this.getResources().getColor(R.color.solid_black));
						tvNoContent.setTextSize(14);
						linearProgramContent.addView(tvNoContent);
					} else {
						// 显示更多按钮
						isShowTXT = true;
						btnMore = new Button(LotteryRecordDetailFootballAct.this);
						btnMore.setText("查看上传方案");
						btnMore.setTextColor(getResources().getColor(R.color.solid_black));
						btnMore.setWidth(LayoutParams.FILL_PARENT);
						btnMore.setId(BUTTON_CHECK_MORE);
						btnMore.setOnClickListener(this);
						linearProgramContent.addView(btnMore);
					}
				}
			} else {
				EDebug.o(this, "方案未上传");
				TextView tvNoContent = new TextView(LotteryRecordDetailFootballAct.this);
				tvNoContent.setText("方案未上传");
				tvNoContent.setTextColor(this.getResources().getColor(R.color.solid_black));
				tvNoContent.setTextSize(14);
				linearProgramContent.addView(tvNoContent);
			}
		} else {

			if (list.getFaQiRen().equals(UserInfo.getUserInfo().getUserName())) {
				if (list.getMatchNum().size() < 1) {
					EDebug.o(this, "无方案");
					TextView tvNoContent = new TextView(LotteryRecordDetailFootballAct.this);
					tvNoContent.setText("无方案");
					tvNoContent.setTextColor(this.getResources().getColor(R.color.solid_black));
					tvNoContent.setTextSize(14);
					linearProgramContent.addView(tvNoContent);
				} else if (list.getMatchNum().size() <= 7) {
					EDebug.o(this, "小于7");
					for (int i = 0; i < list.getMatchNum().size(); i++) {
						addChildContent(list, i);
					}
				} else if (list.getMatchNum().size() > 7) {
					EDebug.o(this, "大于7");
					for (int i = 0; i < 7; i++) {
						addChildContent(list, i);
					}
					// 显示更多按钮
					isShowTXT = false;
					btnMore = new Button(LotteryRecordDetailFootballAct.this);
					btnMore.setText("...");
					btnMore.setTextColor(getResources().getColor(R.color.solid_black));
					btnMore.setWidth(LayoutParams.FILL_PARENT);
					btnMore.setId(BUTTON_CHECK_MORE);
					btnMore.setOnClickListener(this);
					linearProgramContent.addView(btnMore);
				}
			} else {

				if (list.getIsShow().equals("1")) {
					EDebug.o(this, "截止后公开");
					TextView tvNoContent = new TextView(LotteryRecordDetailFootballAct.this);
					tvNoContent.setText("截止后公开");
					tvNoContent.setTextColor(this.getResources().getColor(R.color.solid_black));
					tvNoContent.setTextSize(14);
					linearProgramContent.addView(tvNoContent);
				} else {
					if (list.getMatchNum().size() < 1) {
						EDebug.o(this, "无方案");
						TextView tvNoContent = new TextView(LotteryRecordDetailFootballAct.this);
						tvNoContent.setText("无方案");
						tvNoContent.setTextColor(this.getResources().getColor(R.color.solid_black));
						tvNoContent.setTextSize(14);
						linearProgramContent.addView(tvNoContent);
					} else if (list.getMatchNum().size() <= 7) {
						EDebug.o(this, "小于7");
						for (int i = 0; i < list.getMatchNum().size(); i++) {
							addChildContent(list, i);
						}
					} else if (list.getMatchNum().size() > 7) {
						EDebug.o(this, "大于7");
						for (int i = 0; i < 7; i++) {
							addChildContent(list, i);
						}
						// 显示更多按钮
						btnMore = new Button(LotteryRecordDetailFootballAct.this);
						btnMore.setText("...");
						btnMore.setTextColor(getResources().getColor(R.color.solid_black));
						btnMore.setWidth(LayoutParams.FILL_PARENT);
						btnMore.setId(BUTTON_CHECK_MORE);
						btnMore.setOnClickListener(this);
						linearProgramContent.addView(btnMore);
					}
				}
			}
		}
	}

	// 添加单个比赛内容
	private void addChildContent(LotteryRecordDetailFootballInfo list, int i) {
		EDebug.o(this, "i=" + i);
		View viewContent = LotteryRecordDetailFootballAct.this.getLayoutInflater().inflate(R.layout.lotteryrecord_detailfootball_procontent_table, null);
		// 赛事编号
		TextView tvMatchNum = (TextView) viewContent.findViewById(R.id.lotteryrecord_detailfootball_procontent_table_tv_matchNum);
		tvMatchNum.setText(list.getMatchNum().get(i));
		EDebug.o(this, list.getMatchNum().get(i));
		// 主队
		TextView tvHomeTeam = (TextView) viewContent.findViewById(R.id.lotteryrecord_detailfootball_procontent_table_tv_homeTeam);
		tvHomeTeam.setText(list.getHomeTeam().get(i).replace(" ", ""));
		EDebug.o(this, list.getHomeTeam().get(i));
		// 让球
		TextView tvRangQiu = (TextView) viewContent.findViewById(R.id.lotteryrecord_detailfootball_procontent_table_tv_rangQiu);
		tvRangQiu.setText(list.getRangQiu().get(i));
		EDebug.o(this, list.getRangQiu().get(i));
		// 客队
		TextView tvVisitingTeam = (TextView) viewContent.findViewById(R.id.lotteryrecord_detailfootball_procontent_table_tv_visitingTeam);
		tvVisitingTeam.setText(list.getVisitingTeam().get(i).replace(" ", ""));
		EDebug.o(this, list.getVisitingTeam().get(i));
		// 比分和比赛结果
		TextView tvScore = (TextView) viewContent.findViewById(R.id.lotteryrecord_detailfootball_procontent_table_tv_score);
		TextView tvResult = (TextView) viewContent.findViewById(R.id.lotteryrecord_detailfootball_procontent_table_tv_result);
		if (!list.getScore().get(i).equals("")) {
			tvScore.setText(list.getScore().get(i));
			tvResult.setText("(" + list.getResult().get(i) + ")");
		} else {
			tvScore.setText("未比赛");
			tvResult.setText("");
		}
		EDebug.o(this, list.getScore().get(i));
		EDebug.o(this, list.getRangQiu().get(i));
		// 投注内容
		TextView tvLotteryContentOne = (TextView) viewContent.findViewById(R.id.lotteryrecord_detailfootball_procontent_table_tv_one);
		TextView tvLotteryContentTwo = (TextView) viewContent.findViewById(R.id.lotteryrecord_detailfootball_procontent_table_tv_two);
		TextView tvLotteryContentThree = (TextView) viewContent.findViewById(R.id.lotteryrecord_detailfootball_procontent_table_tv_three);
		EDebug.o(this, list.getLotteryContent().get(i));
		String[] content = list.getLotteryContent().get(i).split(",");
		for (int i1 = 0; i1 < content.length; i1++) {
			EDebug.o(this, content[i1]);
		}
		String[] peiLv = list.getPeiLv().get(i).split(",");
		EDebug.o(this, "pei lv===" + list.getPeiLv().get(i));
		for (int i1 = 0; i1 < peiLv.length; i1++) {
			EDebug.o(this, peiLv[i1]);
		}
		if (peiLv.length == 0) {

		}
		if (content.length >= 1) {
			if (peiLv.length > 0) {
				if (peiLv[0] != null && !peiLv[0].equals("")) {
					tvLotteryContentOne.setText(content[0] + peiLv[0]);
				} else {
					tvLotteryContentOne.setText(content[0]);
				}
			} else {
				tvLotteryContentOne.setText(content[0]);
			}
			EDebug.o(this, tvLotteryContentOne.getText().toString());
			if (content[0].equals(list.getResult().get(i))) {
				tvLotteryContentOne.setTextColor(getResources().getColor(R.color.kjxx_red));
			}
			if (content.length > 1) {
				if (peiLv.length > 1) {
					if (peiLv[1] != null && !peiLv[1].equals("")) {
						tvLotteryContentTwo.setText("," + content[1] + peiLv[1]);
					} else {
						tvLotteryContentTwo.setText("," + content[1]);
					}
				} else {
					tvLotteryContentTwo.setText("," + content[1]);
				}
				if (content[1].equals(list.getResult().get(i))) {
					tvLotteryContentTwo.setTextColor(getResources().getColor(R.color.kjxx_red));
				}
				EDebug.o(this, tvLotteryContentTwo.getText().toString());
				if (content.length >= 3) {
					if (peiLv.length > 2) {
						if (peiLv[2] != null && !peiLv[2].equals("")) {
							tvLotteryContentThree.setText("," + content[2] + peiLv[2]);
						} else {
							tvLotteryContentThree.setText("," + content[2]);
						}
					} else {
						tvLotteryContentThree.setText("," + content[2]);
					}
					if (content[2].equals(list.getResult().get(i))) {
						tvLotteryContentThree.setTextColor(getResources().getColor(R.color.kjxx_red));
					}
					EDebug.o(this, tvLotteryContentThree.getText().toString());
				}
			}
		}
		// 胆
		TextView tvDanMa = (TextView) viewContent.findViewById(R.id.lotteryrecord_detailfootball_procontent_table_tv_dan);
		if (list.getIsDanMa().get(i).equals("1")) {
			tvDanMa.setVisibility(View.VISIBLE);
		}
		EDebug.o(this, list.getIsDanMa().get(i));

		linearProgramContent.addView(viewContent);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.lotteryrecord_detailfootball_act_btn_back:

			LotteryRecordDetailFootballAct.this.finish();

			break;

		case R.id.lotteryrecord_detailfootball_act_btn_cheDan:

			btnChenDanOnClick();

			break;

		case BUTTON_CHECK_MORE:

			if (isShowTXT) {
				Bundle bundle = new Bundle();
				bundle.putString("classify", "web");
				bundle.putString("detailurl", urlTxt + playID + "&pid=" + id);
				bundle.putString(Key.KEY_LOTID, lotid);
				startActivity(new Intent(LotteryRecordDetailFootballAct.this, LotteryRecordDetailMoreAct.class).putExtras(bundle));
			} else {
				btnMore.setVisibility(View.GONE);
				for (int i = 7; i < listInfo.getScore().size(); i++) {
					addChildContent(listInfo, i);
				}
			}

			break;

		default:
			break;
		}
	}

	// 撤单通讯线程
	public void cheDanThread() {
		new Thread() {
			@Override
			public void run() {
				// TODO Auto-generated method stub
				cheDanCommunicater = new CheDanCommunicater();
				EDebug.o(this, "进入撤单线程");
				Message msg = new Message();
				try {
					boolean isSucceed;
					if (fauserName.equals(UserInfo.getUserInfo().getUserName())) {
						isSucceed = cheDanCommunicater.isCheDan(lotid, uid, playID);
					} else {
						isSucceed = cheDanCommunicater.userOrderCheDan(lotid, uid, playID);
					}
					serverMessage = cheDanCommunicater.getMsgServer();
					EDebug.o(this, serverMessage + "  " + cheDanCommunicater.getErrorMSG());
					if (isSucceed) {
						msg.what = CHEDAN_SUCCEED;
					} else {
						msg.what = CHEDAN_FAIL;
					}
					handlerGetLotteryRecordDetail.sendMessage(msg);
				} catch (Exception e) {
					// TODO Auto-generated catch block
					msg.what = Config.CONNECTION_FAIL;
					handlerGetLotteryRecordDetail.sendMessage(msg);
				}
			}
		}.start();
	}

	// 撤单按钮点击事件
	public void btnChenDanOnClick() {
		final Dialog chenDanDialog = new Dialog(LotteryRecordDetailFootballAct.this, R.style.dialog);
		chenDanDialog.getWindow().setContentView(R.layout.dialog_doublebutton_lotteryrecord_detail);
		TextView tvChenDanMsg = (TextView) chenDanDialog.getWindow().findViewById(R.id.dialog_doublebutton_tv_msg);
		tvChenDanMsg.setText("确定对认购方案撤单吗？");
		Button btnChenDanYes = (Button) chenDanDialog.getWindow().findViewById(R.id.dialog_doublebutton_btn_yes);
		btnChenDanYes.setText(getResources().getString(R.string.ok));
		btnChenDanYes.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				cheDanThread();
				chenDanDialog.dismiss();
				progressDialog.show();
			}
		});
		Button btnChenDanNo = (Button) chenDanDialog.getWindow().findViewById(R.id.dialog_doublebutton_btn_no);
		btnChenDanNo.setText(getResources().getString(R.string.cancel));
		btnChenDanNo.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				chenDanDialog.dismiss();
			}
		});
		chenDanDialog.show();
	}

	// 获取发起人头像名称
	private void threadGetUserIcon() {
		new Thread() {
			@Override
			public void run() {
				super.run();
				try {
					getUserIconCommunicater = new GetUserIconCommunicater();
					boolean isSucceed = getUserIconCommunicater.isGetIconNameSucced(fauserName);
					if (isSucceed) {
						Message msg = handlerGetLotteryRecordDetail.obtainMessage(GET_ICONNAME_SUCCEED, null);
						handlerGetLotteryRecordDetail.sendMessage(msg);
					} else {
						Message msg = handlerGetLotteryRecordDetail.obtainMessage(GET_ICONNAME_FAIL, null);
						handlerGetLotteryRecordDetail.sendMessage(msg);
					}
				} catch (Exception e) {
					// TODO: handle exception
					EDebug.o(LotteryRecordDetailFootballAct.this, ".....");
					Message msg = handlerGetLotteryRecordDetail.obtainMessage(GET_ICONNAME_FAIL, null);
					handlerGetLotteryRecordDetail.sendMessage(msg);
				}
			}
		}.start();
	}

	// 下载发起人头像
	private void getAvatar() {
		new Thread() {

			@Override
			public void run() {
				super.run();

				Bitmap bm = null;
				String name = HemaiDetailInfo.getHemaiDetailInfo().getUserIcon();
				ImageDB.getImageDB().open(LotteryRecordDetailFootballAct.this);

				bm = ImageUtils.getLocalImg(name);

				if (bm == null) {
					bm = ImageUtils.downLoadImg(name);
					if (bm != null) {
						Message msg = handlerGetLotteryRecordDetail.obtainMessage(REPLACE_IMAGE, bm);
						handlerGetLotteryRecordDetail.sendMessage(msg);
						ImageUtils.saveImg(name, bm);
					}
				} else {
					Message msg = handlerGetLotteryRecordDetail.obtainMessage(REPLACE_IMAGE, bm);
					handlerGetLotteryRecordDetail.sendMessage(msg);
				}
				ImageDB.getImageDB().close();
			}
		}.start();
	}

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		isShow = false;
		this.unregisterReceiver(ConnectionChangeReceiver.getConnectionChangeReceiver());
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		isShow = true;
		this.registerReceiver(ConnectionChangeReceiver.getConnectionChangeReceiver(), ConnectionChangeReceiver.getIntentFilter());
	}
}